+(function($){
	$.extend({
		"xalert":function(str,fn){
		//同confirm，点击确定返回true，否则返回false
			$("body").append("<div id='XPOPUPCONFIRM2' style='height:100%; width:100%; position:fixed; _position:absolute; top:0; z-index:1000;opacity:0.4; filter: alpha(opacity=40); background-color:#000;'>"
					+"</div><div id='XPOPUPCONFIRMC2' style='position:fixed; _position:absolute; top:30%;left:50%;margin-left:-200px; z-index:1001;width:400px;background-color:#fff;border:3px solid #aaa;padding:20px;'>"+
					str+"<div style='text-align:right;'><button class='btn btn-info btn-xs' id='XPOPUPCONFIRMY2'>确定</button></div></div>");
			$("#XPOPUPCONFIRMY2").click(function(){
				if(!(typeof fn == 'undefined'))fn();
				$("#XPOPUPCONFIRM2").remove();
				$("#XPOPUPCONFIRMC2").remove();
			});
		},
		"xloading":function(str){
			if($("#XPOPUPLOAD").length<1&&str==1){
				$("body").append("<div id='XPOPUPLOAD' style='height:100%; width:100%; position:fixed; _position:absolute; top:0; z-index:9000;opacity:0.6; filter: alpha(opacity=60); background-color:#000;'>"
						+"<img width='45px' height='45px' src='img/loading1.gif' style='position:fixed; _position:absolute; top:30%;left:50%;margin-left:-23px; z-index:1001;opacity:1.0; filter: alpha(opacity=100);'>"
						+"<span id='XLOADSTR' style='font-size:20px;font-weight:900;position:fixed; _position:absolute; top:30%;left:50%;margin-left:-13px;margin-top:11px; z-index:1002;opacity:1.0; filter: alpha(opacity=100);'></span></div>");
			}else if($("#XPOPUPLOAD").length>=1&&str==1){
				$('#XPOPUPLOAD').show();
			}else if(str==0){
				$('#XPOPUPLOAD').hide();
			}
		},
		"xloadingtemp":function(str){
			if($("#XPOPUPLOAD").length<1&&str==1){
				$("body").append("<div id='XPOPUPLOAD' style='height:100%; width:100%; position:fixed; _position:absolute; top:0; z-index:1000;opacity:0.5; filter: alpha(opacity=50); background-color:#000;'>"
						+"</div><img id='XPOPUPLOADIMG' src='img/cj.gif' style='position:fixed; _position:absolute; top:30%;left:30%;margin-left:-23px; z-index:1001;opacity:1.0; filter: alpha(opacity=100);'>");
			}else if($("#XPOPUPLOAD").length>=1&&str==1){
				$('#XPOPUPLOAD').show();
				$('#XPOPUPLOADIMG').show();
			}else if(str==0){
				$('#XPOPUPLOAD').hide();
				$('#XPOPUPLOADIMG').hide();
			}
		},
		"xconfirm":function(str,fn){
		//同confirm，点击确定返回true，否则返回false
			$("body").append("<div id='XPOPUPCONFIRM' style='height:100%; width:100%; position:fixed; _position:absolute; top:0; z-index:1000;opacity:0.4; filter: alpha(opacity=40); background-color:#000;'>"
					+"</div><div id='XPOPUPCONFIRMC' style='position:fixed; _position:absolute; top:30%;left:50%;margin-left:-200px; z-index:1001;width:400px;background-color:#fff;border:3px solid #aaa;padding:20px;'>"+
					str+"<div style='text-align:right;'><button class='btn btn-info btn-xs' id='XPOPUPCONFIRMY'>确定</button>&nbsp;&nbsp;<button id='XPOPUPCONFIRMN' class='btn btn-default btn-xs'>取消</button></div></div>");
			$("#XPOPUPCONFIRMY").click(function(){
				fn(true);
				$("#XPOPUPCONFIRM").remove();
				$("#XPOPUPCONFIRMC").remove();
			});
			$("#XPOPUPCONFIRMN").click(function(){
				fn(false);
				$("#XPOPUPCONFIRM").remove();
				$("#XPOPUPCONFIRMC").remove();
			});
		},
		"xcontent":function(str,fn){
			$("body").append("<div id='XPOPUPCONTENT' style='height:100%; width:100%; position:fixed; _position:absolute; top:0; z-index:1000;opacity:0.4; filter: alpha(opacity=40); background-color:#000;'>"
					+"</div><div id='XPOPUPCONTENTC' style='position:fixed; _position:absolute; top:30%;left:50%;margin-left:-200px; z-index:1001;width:400px;background-color:#fff;border:3px solid #aaa;padding:20px;'>"+
					str+"</div>");
			fn&&fn();
		},
		"xtodb":function(_dboper,_dbtable,obj,str,fn){//数据库操作，表，操作内容，验证条件，回调
			var ele={};
			for(e in obj){
				if(obj[e].id)
				ele[obj[e].id]=obj[e].value;
			}
			ele["_dboper"]=_dboper;
			ele["_dbtable"]=_dbtable;
			ele["_dbarray2"]=str;//列名_列名_...
			$.xxpost("jstodb",ele,function(data){
				fn(data);
			});
		},
		"xpost":function(url,obj,fn){
			$.xloading(1);
			var send=function(){
				$.post(url,obj,fn).error(function(){
					send();
				});
			}
			send();
		},
		"xxpost":function(url,obj,fn){
			var send=function(){
				$.post(url,obj,fn).error(function(){
					send();
				});
			}
			send();
		},
		"xdel":function(dbtable,id){
			$.xconfirm("确定删除么？",function(data){
	 			if(data){
					$.xloading(1);
					$.xtodb("del",dbtable,{},id,function(data){
						if(data==0){
							$.xloading(0);
							$.xalert("删除失败");
						}else{
							location.reload();
						}
					});
				} 
			});
		}
	});
	
	
})(jQuery);
+(function($){
	$.fn.extend({
		"xrili":function(){
			this.each(function(){
				$("#XRILI").remove();
				var that=this;
				var mydate = new Date();
				var myyear=mydate.getFullYear();
				var mymonth=mydate.getMonth()+1;
				var myday=mydate.getDate();//注意getDate是今天的号数，getDay是今天星期几
				var mydays=getDaysInOneMonth(myyear,mymonth);
				$("body").append("<div id='XRILI' style='margin:0;width:177px;height:217px;background-color:#eee;border-style: solid; border-width: 1px;z-index:9900;"
					+"position:absolute;left:"+$(that).offset().left+"px;top:"+($(that).offset().top+32)+"px;'>"
					+"<div style='text-align:center;'>日期选择器</div><select id='XRILIYEARSELECT'></select><select id='XRILIMONTHSELECT'></select><input id='XRILIBUTTONCLOSE' type=button value='关闭' style='font-size:10px;padding:0;width:73px;height:20px;margin:0;' ><div id='XRILIDAYS'></div></div>");
				$("#XRILIBUTTONCLOSE").click(function(){
					$("#XRILI").hide();
				});
				for(var i=0;i<66;i++){
					$("#XRILIYEARSELECT").append("<option>"+(myyear+3-i)+"</option>");
				}
				$("#XRILIYEARSELECT").val(myyear);
				for(i=1;i<=12;i++){
					$("#XRILIMONTHSELECT").append("<option>"+(i)+"</option>");
				}
				$("#XRILIMONTHSELECT").val(mymonth);
				showXRILI(mydays,new Date(myyear+"-"+mymonth+"-1").getDay(),myday,myyear,mymonth,that);
				$("#XRILIYEARSELECT").change(function(){
					mydays=getDaysInOneMonth($(this).val(),$("#XRILIMONTHSELECT").val());
					showXRILI(mydays,new Date($(this).val()+"-"+$("#XRILIMONTHSELECT").val()+"-1").getDay(),myday,$(this).val(),$("#XRILIMONTHSELECT").val(),that);
				});
				$("#XRILIMONTHSELECT").change(function(){
					mydays=getDaysInOneMonth($("#XRILIYEARSELECT").val(),$(this).val());
					showXRILI(mydays,new Date($("#XRILIYEARSELECT").val()+"-"+$(this).val()+"-1").getDay(),myday,$("#XRILIYEARSELECT").val(),$(this).val(),that);
				});
			});
		},
		"xautocomplete":function(array){
			$("#XAUTOCOMPLETE").remove();
			var that=this;
			//if($(that).val()==""){
				$("body").append("<div id='XAUTOCOMPLETE' style='margin:0;width:150px;height:auto;background-color:#fff;border-style: solid; border-width: 1px;z-index:9900;font-size:9px;"
						+"position:absolute;left:"+$(that).offset().left+"px;top:"+($(that).offset().top+32)+"px;'></div>");
				for(var arr in array){
					$("#XAUTOCOMPLETE").append("<div class='XAUTOCOMPLETE' style='margin-left:10px;cursor:pointer;' onMouseOver=\"this.style.textDecoration='underline'\" onMouseOut=\"this.style.textDecoration='none'\">"+array[arr]+"</div>");
				}
				$("#XAUTOCOMPLETE").append("<div class='XAUTOCOMPLETE' style='text-align:center;width:100%;cursor:pointer;'>关闭</div>");
				$(".XAUTOCOMPLETE").click(function(){
					if($(this).text()!='关闭')
						$(that).val($(this).text());
					$("#XAUTOCOMPLETE").remove();
				});
			//}
		},
		"xxfile":function(obj,fn){
			var that=this;
			var eid=that[0].id;
			var _obj={
				url:"admin_defaultUp.php",
				accept:"",
				data:{},
				autoup:true,
				maxsize:2*1024*1024,//Byte
				multiple:false,
				success:function(data){
							var _k=this.k;
							document.getElementById(eid+"_prostatus_"+_k).innerHTML=(data==1?"处理成功":"<span style='color:red;'>消息！["+data+"]</span>");
							setTimeout(function(){
								$("#"+eid+"_progressbar_"+_k).hide(2000);
							},10000);
						},
				error:function(data){
							uploadrun();
						}
			};
			$.extend(_obj,obj);
			that[0].accept=_obj.accept||that[0].accept;
			that[0].multiple=_obj.multiple||that[0].multiple;
			var uploadrun=function(){
				$.each(that[0].files,function(k,v){
					that.after("<div id='"+eid+"_progressbar_"+k+"' style='padding:2px;margin:3px;border:1px solid #99d9ea;'><div style='font-size:8px;'>"+v.name+" <span id='"+eid+"_prostatus_"+k+"'>上传中。。。</span></div><progress id='"+eid+"_progress_"+k+"' max='100' value='0' style='width:100%;height:5px;'></progress></div>");
					if(v.size<=_obj.maxsize){
						var formdata=new FormData();
						formdata.append("file",v);
						formdata.append("fileSize",v.size);
						formdata.append("progressbarID",k);
						for(e in _obj.data){
							formdata.append(e,_obj.data[e]);
						}
						$.ajax({
							url:_obj.url,  
							type: 'POST',  
							data: formdata, 
							cache: false,
							context:{k:k},
							contentType: false,
							processData: false,  
							success:_obj.success,
							error:_obj.error,
							xhr:function() {
								myXhr = $.ajaxSettings.xhr();
								if(myXhr.upload){
									myXhr.upload.addEventListener('progress',function(event){
										if(event.lengthComputable){
											var complete=(event.loaded/event.total*100|0);
											document.getElementById(eid+"_progress_"+k).innerHTML=complete;
											document.getElementById(eid+"_progress_"+k).value=complete;
											//console.log(v.name+complete);
											if(complete==100){
												document.getElementById(eid+"_prostatus_"+k).innerHTML="稍等。。。";
											}
										}
									}, false);
								}
								return myXhr;
							}
						});
					}else{
						document.getElementById(eid+"_prostatus_"+k).innerHTML="<span style='color:red;'>消息！[文件过大]</span>";
						setTimeout(function(){
							$("#"+eid+"_progressbar_"+k).hide(2000);
						},15000);
					}
				});
			}
			if(_obj.autoup){
				this.change(uploadrun);
			}else{
				if(typeof fn=='function'){
					this.change(function(){fn(that[0].files)});
				}
				this['startup']=function(obj){
					if(obj){
						$.extend(_obj,obj);
					}
					uploadrun();
				}
				//console.log(this);
				return this;
			}
		},
		'xradioSelected':function(d){
			this.each(function(k,v){
				if(v.value==d){
					v.checked=true;
				}
			});
		}
	});
})(jQuery);
function getDaysInOneMonth(year,month){
	month = parseInt(month, 10);
	var d= new Date(year, month, 0);
	return d.getDate();
}
function showXRILI(days,day,myday,year,month,that){//年，月，一个月的天数，第一天是星期几（0为星期日）;显示日期面板
	$("#XRILIDAYS").empty();
	$("#XRILIDAYS").append("<div style='margin:0;background-color:#fff;float:left;width:25px;height:25px;border-style: solid; border-width: 1px;text-align: center;'>日</div>");
	$("#XRILIDAYS").append("<div style='margin:0;background-color:#fff;float:left;width:25px;height:25px;border-style: solid; border-width: 1px;text-align: center;'>一</div>");
	$("#XRILIDAYS").append("<div style='margin:0;background-color:#fff;float:left;width:25px;height:25px;border-style: solid; border-width: 1px;text-align: center;'>二</div>");
	$("#XRILIDAYS").append("<div style='margin:0;background-color:#fff;float:left;width:25px;height:25px;border-style: solid; border-width: 1px;text-align: center;'>三</div>");
	$("#XRILIDAYS").append("<div style='margin:0;background-color:#fff;float:left;width:25px;height:25px;border-style: solid; border-width: 1px;text-align: center;'>四</div>");
	$("#XRILIDAYS").append("<div style='margin:0;background-color:#fff;float:left;width:25px;height:25px;border-style: solid; border-width: 1px;text-align: center;'>五</div>");
	$("#XRILIDAYS").append("<div style='margin:0;background-color:#fff;float:left;width:25px;height:25px;border-style: solid; border-width: 1px;text-align: center;'>六</div>");
	for(i=1;i<=day;i++){
		$("#XRILIDAYS").append("<div style='margin:0;background-color:#fff;float:left;width:25px;height:25px;border-style: solid; border-width: 1px;text-align: center;'></div>");
	}
	for(i=1;i<=days;i++){
		$("#XRILIDAYS").append("<div class='XRILICLASS' style='margin:0;cursor:pointer;background-color:#"+((i==myday)?"0f0":"fff")+";float:left;width:25px;height:25px;border-style: solid; border-width: 1px;text-align: center;'>"+i+"</div>");
	}
	$(".XRILICLASS").click(function(){
		i=parseInt($(this).text());
		$(that).val(year+"-"+((month<10)?("0"+month):month)+"-"+((i<10)?("0"+i):i));
		$("#XRILI").hide();
	});
}
function _isidcard(idcard){
	var reg=/\b[0-9]{17}[0-9x]\b/i;
	if(reg.test(idcard)){
		var map=[1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2];
		var sum=0,s;
		for(var i=17;i>0;i--){
			s=Math.pow(2,i)%11;
			sum+=s*idcard[17-i];
		}
		if(map[sum%11]==idcard.charAt(17)){
			return true;
		}
	}
	return false;
}
lS=localStorage;//将本地存储简化